package com.hooper.redisdemo.controller;

import com.hooper.redisdemo.domain.User;
import com.hooper.redisdemo.service.BlogService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Tim Hooper
 * @version 1.0
 * @time 2023/02/24/18:25
 */
@RestController
@RequestMapping("/blog/")
public class BlogController {
    @Resource
    private BlogService blogService;

    @PostMapping("likeOrNot/{userId}/{blogId}")
    public String likeOrNot(@PathVariable Long blogId, @PathVariable Long userId) {
        return blogService.likeOrNot(userId, blogId);
    }

    @GetMapping("like/top5/{blogId}")
    public List<User> top5Like(@PathVariable Long blogId) {
        return blogService.topLikeUser(blogId);
    }
}
